package 数组.和为S的两个数字;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/3/15 17:24
 * @description:剑指offer
 * @version:
 */
public class Solution {
    public static void main(String[] args) {

    }

    public static int[] twoSum(int[] nums, int target) {
        int i = 0, j = nums.length - 1;
        while(i < j) {
            int s = nums[i] + nums[j];
            if(s < target) i++;
            else if(s > target) j--;
            else return new int[] { nums[i], nums[j] };
        }
        return new int[0];
    }

}
